package ufo.domain

import api.common.Position
import collection.mutable.HashMap
import java.util.UUID

abstract class Being(val id : UUID, var position : Position, var maxHitPoints : Int) {
  var hitPoints : Int = maxHitPoints
}

trait BeingContainer[B <: Being] {
  val beings = new HashMap[UUID, B]

  def add(being : B) = {
    beings(being.id) = being
  }

  def getBeing(id : UUID) : Option[B] = {
    if (beings.contains(id)) {
      Some(beings(id))
    } else {
      None
    }
  }

  def findBeingAt(position: Position) = {
    beings.values.find(b => (b.position equals position))
  }

}